﻿<!DOCTYPE html>
<html>
  <head>
    <title>MyHtml.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/aaa.css">
	<!-- <script src="js/jquery-3.1.0.min.js"></script> -->
	<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/city2.js"></script>
	<script type="text/javascript" src="js/citySelect2.js"></script>
	<style type="text/css">
		#l-map{height:500px;width:100%;}
		#r-result{width:60%;}
		.mymodal{width:60%;}
	</style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=BK1nKL02Lul9X8RURxIvqGhORqsGigsB"></script>
  </head>
  
<body>
<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#inverseNavbar1"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
      <a class="navbar-brand" href="#">Brand</a></div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="inverseNavbar1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link<span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown<span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown<span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>
<div  id="total" class="container-fluid">
		<div id="nav" class="navbar navbar-default navbar-fixed-top" role="navigation">
		
		</div>
		
		<form role="form" id="asform">
		
		<div id="message" class="">
				a
		<div>	
		
		<div id="body" class="row">
		
			
			<div id="send" class="form-group container col-md-4">
				<h3><span class="label label-primary">寄件人信息</span></h3>
				
				<label>姓名</label>
				<input type="text" class="form-control" placeholder="输入姓名">
				<br>
				<label>联系电话</label>
				<input type="text" class="form-control" placeholder="输入电话">
				<br>
				<br>
				<label> 寄件人地址</label>
				<input type="text" class="form-control" placeholder="请根据提示框定位到目标地点附近，确保地址正确" id="fromAddr">
                <input TYPE="hidden" id="fromLNG" value=""/>
                <input TYPE="hidden" id="fromLAT" value=""/>
			</div>
			<div id="get" class=" form-group container col-md-4">
				
				<h3><span class="label label-primary">收件人信息</span></h3>
				
				<label>姓名</label>
				<input type="text" class="form-control" placeholder="输入姓名">
				<br>
				<label>联系电话</label>
				<input type="text" class="form-control" placeholder="输入电话">
				<br>
				<br>
				<label>收件人地址</label>
				<input type="text" class="form-control" placeholder="请根据提示框定位到目标地点附近，确保地址正确" id="toAddr">
                <input TYPE="hidden" id="toLNG" value=""/>
                <input TYPE="hidden" id="toLAT" value=""/>
			</div>
			
			<div id="goods" class="form-group container col-md-4">
				
				<h3><span class="label label-primary">物件信息</span></h3>

				<label>备注</label>
				<textarea class="form-control" rows="3" clos="20" placeholder="输入备注"></textarea>
				<br>

				<div class="input-group">
				  <span class="input-group-addon">重量</span>
				  <input type="text" class="form-control">
				  <span class="input-group-addon">KG</span>
				</div>
				<br>
				
				<div class="input-group">
				  <span class="input-group-addon">体积</span>
				  <input type="text" class="form-control">
				  <span class="input-group-addon">M<sup>3</sup></span>
				</div>
				
				<br><br>
				
				
			</div>
			
			</div>
			<div id="btn_submit" class="">
				<div class="container">
					<button type="submit" class="btn btn-primary btn-lg">提交订单</button>
				</div>
			</div>
			</form>
			
			
			
		<div id="foot" class=" row navbar navbar-default navbar-fixed-bottom" role="navigation">
			<div class="col-md-12">
				<span style="color:#f1f4f5;">_</span>
			<div>
			<div class="col-md-6 col-md-offset-1">
			<p>© 2016. All RIGHT RESERVED. 玛德菲快递有限公司 版权所有 粤ICP备879453134号</p>
			</div>
			<div class="col-md-4">
			<p> 客服服务热线：25041，020-88877766</p>
			</div>
		</div>
	</div>
	
	
	<!-- 地图模态框-->
			
			<!-- Modal -->
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			  <div class="modal-dialog mymodal">
				<div class="modal-content">
				  <div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h4 class="modal-title" id="myModalLabel">选择地址</h4>
				  </div>
				  <div class="modal-body">
				
					<div class="modal-body">	
						<br>
						地址：<input type="text" id="suggestId" value="百度" style="width:60%; readonly="readonly"/>	
						<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
                        <br>
						<div id="l-map">
						</div>
				  </div>
				  </div>
				  <div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				  </div>
				</div>
			  </div>
			</div>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
    var fromplace=0;
	var toplace=0;
	function G(id) {
		return document.getElementById(id);
	}

	var map = new BMap.Map("l-map");
	map.centerAndZoom("广州",12);                   // 初始化地图,设置城市和地图级别。
  	map.enableScrollWheelZoom();
	var geoc = new BMap.Geocoder();  
	var acfrom = new BMap.Autocomplete(    //建立一个自动完成的对象
		{"input" : "fromAddr" //指定输入的文本框
		,"location" : map
	});

	acfrom.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
	var str = "";
		var _value = e.fromitem.value;
		var value = "";
		if (e.fromitem.index > -1) {
			value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		}    
		str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
		
		value = "";
		if (e.toitem.index > -1) {
			_value = e.toitem.value;
			value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		}    
		str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
		G("searchResultPanel").innerHTML = str;
	});

	var myValue;
	acfrom.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
    	
	var _value = e.item.value;
		myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
		$('#myModal').modal('show');
		setPlacefrom();
	});

	function setPlacefrom(){
		map.clearOverlays();    //清除地图上所有覆盖物
		function myFun(){
			var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
			map.centerAndZoom(pp, 18);
            var ppmarker = new BMap.Marker(pp);
			map.addOverlay(ppmarker);    //添加标注
            ppmarker.enableDragging();
          	ppmarker.addEventListener("dragend",overlay_style);
			geoc.getLocation(ppmarker.point, function(rs){
			  var addComp = rs.addressComponents;
              document.getElementById("suggestId").value=
			  addComp.province + addComp.city  + addComp.district  + addComp.street + addComp.streetNumber;
              $("#fromAddr").val($("#suggestId").val());
			});
            $("#fromLNG").val(pp.lng);
            $("#fromLAT").val(pp.lat);
		}
		var local = new BMap.LocalSearch(map, { //智能搜索
		  onSearchComplete: myFun
		});
        fromplace=1;
		local.search(myValue);
	}
  	function overlay_style(e){
              var p = e.target.point;
              geoc.getLocation(p, function(rs){
			  var addComp = rs.addressComponents;
              document.getElementById("suggestId").value=
			  addComp.province + addComp.city  + addComp.district  + addComp.street + addComp.streetNumber;
              $("#fromLNG").val(p.lng);
              $("#fromLAT").val(p.lat);
              $("#fromAddr").val($("#suggestId").val());
		});
     
     }
     	var acto = new BMap.Autocomplete(    //建立一个自动完成的对象
		{"input" : "toAddr" //指定输入的文本框
		,"location" : map
	});

	acto.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
	var str = "";
		var _value = e.fromitem.value;
		var value = "";
		if (e.fromitem.index > -1) {
			value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		}    
		str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
		
		value = "";
		if (e.toitem.index > -1) {
			_value = e.toitem.value;
			value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		}    
		str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
		G("searchResultPanel").innerHTML = str;
	});

	var myValue;
	acto.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
    	
	var _value = e.item.value;
		myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
		$('#myModal').modal('show');
		setPlaceto();
	});

	function setPlaceto(){
		map.clearOverlays();    //清除地图上所有覆盖物
		function myFun(){
			var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
			map.centerAndZoom(pp, 18);
            var ppmarker = new BMap.Marker(pp);
			map.addOverlay(ppmarker);    //添加标注
            ppmarker.enableDragging();
          	ppmarker.addEventListener("dragend",overlay_style);
			geoc.getLocation(ppmarker.point, function(rs){
			  var addComp = rs.addressComponents;
              document.getElementById("suggestId").value=
			  addComp.province + addComp.city  + addComp.district  + addComp.street + addComp.streetNumber;
              $("#toAddr").val($("#suggestId").val());
			});
            $("#toLNG").val(pp.lng);
            $("#toLAT").val(pp.lat);
		}
		var local = new BMap.LocalSearch(map, { //智能搜索
		  onSearchComplete: myFun
		});
        toplace=1;
		local.search(myValue);
	}
  	function overlay_style(e){
              var p = e.target.point;
              geoc.getLocation(p, function(rs){
			  var addComp = rs.addressComponents;
              document.getElementById("suggestId").value=
			  addComp.province + addComp.city  + addComp.district  + addComp.street + addComp.streetNumber;
              $("#toLNG").val(p.lng);
              $("#toLAT").val(p.lat);
              $("#toAddr").val($("#suggestId").val());
		});
     
     }
</script>
